home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / c01lab1.zip / SIMLATRS / SSI.BDY < prev    next >
Text File  |  1992-11-11  |  3KB  |  83 lines

  1. -- **************************************************
  2. -- *                                                *
  3. -- *  Spacecraft_Sensor_Interface                   *  BODY
  4. -- *                                                *
  5. -- **************************************************
  6. package body Spacecraft_Sensor_Interface is
  7.  
  8.   type PRESSURE_TABLE is array (NATURAL range <>) of PRESSURE;
  9.   type TEMPERATURE_TABLE is array (NATURAL range <>) of TEMPERATURE;
  10.   type RADIATION_TABLE is array (NATURAL range <>) of RADIATION_LEVEL;
  11.   type INDEX_VECTOR is array (SPACECRAFT_SECTION) of NATURAL;
  12.  
  13.   P_Index : INDEX_VECTOR :=
  14.     (5, 2, 1, 4, 3, 7, 6, 8, 9, 10);
  15.   T_Index : INDEX_VECTOR :=
  16.     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  17.   R_Index : INDEX_VECTOR :=
  18.     (10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
  19.  
  20.   P_Table : constant PRESSURE_TABLE :=
  21.     (32.5, 32.5, 32.5, 32.5, 50.0, 75.0, 80.0, 90.0, 110.0, 32.5, 32.5,
  22.      20.0, 10.0, 30.0, 32.5, 32.5, 40.0, 250.0, 32.5);
  23.   T_Table : constant TEMPERATURE_TABLE :=
  24.     (70.0, 70.0, 71.0, 75.0, 80.0, 100.0, 120.0, 140.0, 130.0, 140.0,
  25.      135.0, 130.0, 125.0, 120.0, 100.0, 80.0, 75.0, 73.0, 70.0);
  26.   R_Table : constant RADIATION_TABLE :=
  27.     (10.0, 20.0, 15.0, 20.0, 50.0, 100.0, 400.0, 500.0, 600.0, 700.0,
  28.      1000.0, 50.0, 30.0, 20.0, 10.0, 5.0, 5.0, 8.0, 10.0);
  29.  
  30.   -- .................................................
  31.   -- .                                               .
  32.   -- .  Spacecraft_Sensor_Interface.Sensed_Value     .  BODY
  33.   -- .                                               .
  34.   -- .................................................
  35.   function Sensed_Value
  36.       (Location : in SPACECRAFT_SECTION) return PRESSURE is
  37.   begin
  38.     return P_Table(P_Index(Location));
  39.   end Sensed_Value;
  40.  
  41.   function Sensed_Value
  42.       (Location : in SPACECRAFT_SECTION) return TEMPERATURE is
  43.   begin
  44.     return T_Table(T_Index(Location));
  45.   end Sensed_Value;
  46.  
  47.   function Sensed_Value
  48.       (Location : in SPACECRAFT_SECTION) return RADIATION_LEVEL is
  49.   begin
  50.     return R_Table(R_Index(Location));
  51.   end Sensed_Value;
  52.  
  53.   -- .................................................
  54.   -- .                                               .
  55.   -- .  Spacecraft_Sensor_Interface.Update           .  SPEC
  56.   -- .                                               .
  57.   -- .................................................
  58.   procedure Update is
  59.  
  60.   begin
  61.  
  62.     for Location in SPACECRAFT_SECTION loop
  63.       P_Index(Location) := P_Index(Location) + 1;
  64.       if P_Index(Location) > P_Table'LAST then
  65.         P_Index(Location) := 0;
  66.       end if;
  67.  
  68.       T_Index(Location) := T_Index(Location) + 1;
  69.       if T_Index(Location) > T_Table'LAST then
  70.         T_Index(Location) := 0;
  71.       end if;
  72.  
  73.       R_Index(Location) := R_Index(Location) + 1;
  74.       if R_Index(Location) > R_Table'LAST then
  75.         R_Index(Location) := 0;
  76.       end if;
  77.     end loop;
  78.  
  79.   end Update;
  80.  
  81. end Spacecraft_Sensor_Interface;
  82.  
  83.